package edu.langnan.xiaoli.controller.common;

import edu.langnan.xiaoli.base.AjaxResult;
import edu.langnan.xiaoli.base.controller.BaseController;
import edu.langnan.xiaoli.core.dto.VolunteerDTO;
import edu.langnan.xiaoli.core.page.TableDataInfo;
import edu.langnan.xiaoli.service.VolunteerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cql
 */
@RestController
@RequestMapping("common/volunteer")
public class CommonVolunteerController extends BaseController {

    @Autowired
    private VolunteerService volunteerService;

    /**
     * 分页获取志愿者活动列表
     *
     * @return
     */
    @GetMapping("list")
    public TableDataInfo volunteerList() {
        startPage();
        List<VolunteerDTO> result = volunteerService.volunteerList();
        return getDataTable(result);
    }

    /**
     * 获取志愿活动基本信息
     *
     * @param vid
     * @return
     */
    @GetMapping("{vid}")
    public AjaxResult findVolunInfo(@PathVariable("vid") Integer vid) {
        VolunteerDTO result = volunteerService.findVolunInfo(vid);
        return AjaxResult.success(result);
    }


}
